package com.breaking.second.activity.pager.adapter;

import android.content.Context;

import com.breaking.second.databinding.ItemImageBinding;
import com.bumptech.glide.Glide;

import java.io.File;
import java.util.List;

public class ImageAdapter extends BaseAdapter<ItemImageBinding> {
    private final List<String> images;

    public ImageAdapter(Context context, List<String> images) {
        super(context);
        this.images = images;
    }

    @Override
    public void onBindViewHolder(ItemImageBinding binding, int position) {
        if (images.get(position).startsWith("http")) {
            Glide.with(getContext()).load(images.get(position)).into(binding.image);
        } else {
            Glide.with(getContext()).load(new File(images.get(position))).into(binding.image);
        }
    }

    @Override
    public int getItemCount() {
        return images.size();
    }
}
